﻿#define  _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
#include<math.h>


int Sixteen_Ten(char* p)
{
	int k = 0;
	int i = 0;
	int sum = 0;
	int len = strlen(p);
	for (i = len - 1; i >= 0; i--)
	{
		if (p[i] >= 'A' && p[i] <= 'F')
		{
			sum += (p[i] - 'A' + 10) * (int)pow(16 * 1.0, k++ * 1.0);
		}
		else
		{
			sum += (p[i]-'0') * (int)pow(16 * 1.0, k++ * 1.0);
		}
	}
	return sum;
}
void PrintNum(int* ret, int len)
{
	int left = 0;
	int right = len-1;
	while (left<right)
	{
		int tmp = ret[right];
		ret[right] = ret[left];
		ret[left] = tmp;
		right--;
		left++;
	}
	int k = len;
	int sum = 0;
	for (int i = 0; i < len; i++)
	{
		sum = sum + ret[i]*pow(10, --k);
	}
	printf("%d",sum);
}
void Ten_Eight(int num)
{
	int ret[99] = { 0 };
	int i = 0;
	int k = 0;
	while (num)
	{
		ret[k++] = num % 8;
		num /= 8;
	}
	
	PrintNum(ret, k);
}
int main()
{
	char arr[100]="AB";
	
	int n=Sixteen_Ten(arr);
	Ten_Eight(n);

	return 0;
}

